<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
$return=array();
if($_RQ['op']=='edit'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('goodsbasic',$postdata);
		exi('设置成功');
	}
	$item=$this->plugin_setting('goodsbasic');
	$plugins = $this->plugins();
    $return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'desc'=>'设置',
		'edit_tab'=>true,
		'edits'=>array(
				array(
				'title'=>'固定信息',
					'list'=>array(
						array('name'=>'dispatchtype','title'=>'运费类型','type'=>'radio','options'=>'dispatchtype'),
						array('name'=>'template_id','title'=>'运费模版','type'=>'select','options'=>'dispatchid','show'=>array('dispatchtype'=>0)),
						array('name'=>'dispatchprice','title'=>'统一运费','type'=>'string','show'=>array('dispatchtype'=>1),'help'=>'统一运费后发往各地运费一致'),
						array('name'=>'footerinfo','title'=>'商品描述底部统一信息','type'=>'richtext','help'=>'统一底部信息。例如：包邮，包退，发货时间信息等设置'),
					)
				),
				array(
					'title'=>'购买须知',
					'list'=>array(
						array('type'=>'richtext','title'=>'购买须知','name'=>'buyread'),
					)
				),
			)
	);
	$return['dispatchid']=pdo_getall('jy_weishop_dispatch',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),array('id','title'),'id');
	$return['dispatchtype']=array('0'=>'运费模板','1'=>'统一运费');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='chooseplugins'){
	$list = pdo_getall('core_plugins',array('hide'=>0),array('id','style','name','title','image','description'),'id');
	if($list){
		foreach($list as $k=>&$item){
			if(!check_permission($item['name'])){
				unset($list[$k]);
			}else{
				$item['plugininfo'] = array('name'=>$item['name'],'title'=>$item['title'],'description'=>$item['description']);
			}
			
		}
	}
	$return['list']=$list;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'名称','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'name','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	exi($return);
}
?>